﻿<cfscript>
/** 
* ORM GraduateCondition
* 
* @hint "Hibernate persistenter t_condition. 各专业年级的毕业学分、学时要求" 
* 
*/ 

component 
	displayname="public.service.orm.senate.GraduateCondition" 
	output=false 
	persistent=true 
	selectBeforeUpdate=true dynamicInsert=true dynamicUpdate=true 
	cacheuse="Transactional" 
	entityname="GraduateCondition" 
	table="t_condition"
	{
	
	property type="string" name="ConditionID" column="con_id" fieldtype="id" generator="assigned" hint="专业计划号";

	property type="string" name="Grade" column="grade" hint="年级";
	property type="numeric" name="Credit" column="credit" hint="总学分要求";
	property type="numeric" name="CreditRequired" column="credit_required" hint="必修学分要求";
	property type="numeric" name="CreditOptional" column="credit_optional" hint="限选学分要求";
	property type="numeric" name="CreditRelish" column="credit_relish" hint="任选课学分要求";
	property type="numeric" name="Period" column="period" hint="总学时数";
	property type="numeric" name="PeriodRequired" column="period_required" hint="必修学时要求";
	property type="numeric" name="PeriodOptional" column="period_optional" hint="限选学时要求";

	property type="string" name="SchemaFound" column="found_date" hint="专业计划起始年月";

	property name="Subject" fieldtype="many-to-one" fkcolumn="sbj_id" cfc="Subject"  hint="专业";

	/**
	* @hint "自定义主键规则"
	* 
	* @Subject "专业"
	* @Grade "年级"
	*/
	public string function getID( required Subject, required string Grade ) output=false {
		
		var nextID = arguments.Grade & left(arguments.Subject.getSubjectID(), 5);

		/* 
			主键生成规则 
			
			专业计划号为9位 4位为年级 + 5位专业代码
			
			Unique: GRADE, SBJ_ID
		*/
		return nextID;
	}
	
}

</cfscript>
